package com.qf.service;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.qf.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

/**
 * @author sunyamei
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.service
 * @Description:
 * @Date 2022/8/17 11:41
 */
@Service
public class UserAServiceImpl implements  UserAService{

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private RestTemplate restTemplate;


    @Transactional
    @LcnTransaction
    @Override
    public Integer decrA() {
        //1:a账户扣款
        Integer decr = userMapper.decr();

        //2:返程调用b微服务,进行b账户加款
        Integer count2 = restTemplate.getForObject("http://localhost:8081/userb/incr", Integer.class);

        return count2;
    }
}
